package com.test2015.Swing.table;

import java.awt.Color;
import java.awt.Container;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;

public class Test extends JFrame
{
	private static final long serialVersionUID = 20110124L;

	public Test()
	{
		Container container = this.getContentPane();

		this.setBounds(0, 0, 600, 600);

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBorder(new CompoundBorder(new TitledBorder("scrollPane的外边框"),new EmptyBorder(8, 8, 8, 8)));
		JViewport viewport = scrollPane.getViewport();
		viewport.setBackground(Color.WHITE);
		
		container.add(scrollPane);

		String[] columnNames = { "aa", "bb" };
		String[][] value = { { "11", "22" }, { "33", "44" } };
		JTable table = new JTable(value, columnNames);
		table.setShowGrid(false);
		scrollPane.setViewportView(table);

		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public static void main(String[] args)
	{
		new Test();
	}

}

